﻿@model NK.Mvc3.Models.SaleDetail

@using (Ajax.BeginForm("InsertSaleDetail", "SaleAjax", null, new AjaxOptions
{
    HttpMethod = "POST",
    InsertionMode = InsertionMode.InsertBefore,
    UpdateTargetId = "gridbody",
    OnSuccess = "clearData"
}, new { @id = "ajaxcreateform" }))
{

    <div class="gridcell">
        @Html.TextBox("dtupdateBarCode", null, new { @class = "grid-textbox-text",
                                                        onchange = "changeBarCode(this,'hdProductInfoID','dtupdatePOSDescription')"})
        @Html.ValidationMessage("dtupdateBarCode")
        @if (ViewBag.SaleID != null)
        {
            Html.HiddenFor(model => model.SaleID, new {Value = ViewBag.SaleID, id = "hdStoreInputID"});
        }
        @*@Html.HiddenFor(model => model.SaleID, new { Value = ViewBag.SaleID, id = "hdStoreInputID" })*@
        @*@Html.ValidationMessageFor(model => model.SaleID)*@

        @Html.HiddenFor(model => model.ProductInfoID, new {id = "hdProductInfoID"})
        @Html.ValidationMessageFor(model => model.ProductInfoID)

    </div>
    <div class="gridcell text">
        @Html.TextBox("dtupdatePOSDescription", null, new {@class = "grid-textbox-text", disabled = "disabled"})
    </div>
    <div class="gridcell num">
        @Html.TextBoxFor(model => model.Quantity, new {@class = "grid-textbox-num"})
        @Html.ValidationMessageFor(model => model.Quantity)
    </div>
    <div class="gridcell money">
        @Html.TextBoxFor(model => model.CostSale, new {@class = "grid-textbox-num"})
        @Html.ValidationMessageFor(model => model.CostSale)
    </div>
    <div class="gridcell money">
        @Html.TextBoxFor(model => model.TotalCost, new {@class = "grid-textbox-num"})
        @Html.ValidationMessageFor(model => model.TotalCost)
    </div>  
    <div class="gridcell action">
        <input type="submit" value="Insert" />
    </div>
}

<script type="text/javascript">
    $(function () {
        //Using this script when the paritial form is loaded by ajax, to set the validate on
        $.validator.unobtrusive.parse("#ajaxcreateform");
     });
</script>